<html>
<head><meta charset="utf-8"><title>mod&lt;|&gt; completion · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/mod.3C.7C.3E.20completion.html">mod&lt;|&gt; completion</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="208384398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/mod%3C%7C%3E%20completion/near/208384398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/mod.3C.7C.3E.20completion.html#208384398">(Aug 28 2020 at 19:17)</a>:</h4>
<p>I'd like to provide a list of module names to complete after <code>mod </code> input in the file, but not sure how to get this list properly.</p>
<p>Looksl ike I cannot use <code>hir</code> for this task, because there can be Rust files that were never declared in any <code>mod </code>.<br>
I think the task can be done by looking at the FS and listing the module directory contents, but I have not found any way to actually do that.</p>
<p>Am I on the right path? Any code pointers I can use?</p>



<a name="208402699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/mod%3C%7C%3E%20completion/near/208402699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/mod.3C.7C.3E.20completion.html#208402699">(Aug 28 2020 at 22:45)</a>:</h4>
<p>This is definitelly outside of <code>hir</code> I belive, as <code>hir</code> shouldn't know what files are there, besides thouse explicitely linked via mod decls</p>



<a name="208402753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/mod%3C%7C%3E%20completion/near/208402753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/mod.3C.7C.3E.20completion.html#208402753">(Aug 28 2020 at 22:46)</a>:</h4>
<p>But <code>ide</code> / <code>ide_db</code> <em>should</em> have enough info to compute that I think, at least in theory</p>



<a name="208402784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/mod%3C%7C%3E%20completion/near/208402784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/mod.3C.7C.3E.20completion.html#208402784">(Aug 28 2020 at 22:46)</a>:</h4>
<p>The question is, does our VFS impl actually allows us to do that, in a way which isn't as stupid as just listing all files?</p>



<a name="208402813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/mod%3C%7C%3E%20completion/near/208402813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/mod.3C.7C.3E.20completion.html#208402813">(Aug 28 2020 at 22:47)</a>:</h4>
<p>I think the answer is "probably not yet", but I also don't think that listing all files from a specific root would be problemantic in this case.</p>



<a name="208421288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/mod%3C%7C%3E%20completion/near/208421288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/mod.3C.7C.3E.20completion.html#208421288">(Aug 29 2020 at 07:08)</a>:</h4>
<p>Hm, I don't recall any good way to get to VFS in the completion context, but I'll recheck, thanks.</p>



<a name="208424675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/mod%3C%7C%3E%20completion/near/208424675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/mod.3C.7C.3E.20completion.html#208424675">(Aug 29 2020 at 08:58)</a>:</h4>
<p><span class="user-mention" data-user-id="231447">@Kirill Bulatov</span> I don't remmember the details, but <code>ide_db</code> computes the <code>fst</code> of local symbols on per-file basis, so it should have some extra access to files</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>